import os

root_path = "/Users/tyz/photlab/pyphot-server/phot_server/database/component_library"
full_file_paths = []
for root, dirs, files in os.walk(root_path):
    if len(dirs) == 0:
        for file in files:
            if file.endswith("phtc"):
                full_file_paths.append(os.path.join(root, file))
count = 0
file_data = ""
for full_file_path in full_file_paths:
    with open(full_file_path, "r") as f:
        for line in f:
            # if "[Component.parameters]" in line:
            #     line = line.replace("[Component.parameters]", "")
            if '[[Component.parameters.""]]' in line:
                line = line.replace(
                    '[[Component.parameters.""]]', "[[Component.parameters]]"
                )
            file_data += line
            # print(line)
            # count += 1
    with open(full_file_path, "w") as f:
        f.write(file_data)
    file_data = ""
